import request from '@/utils/request'
import upload from '@/utils/upload'
// 查询设备详细
export function getEquipment(equipmentNo) {
  return request({
    url: '/mk/equipments/' + equipmentNo,
    method: 'get'
  })
}

// 删除设备
export function delEquipment(equipmentNo) {
  return request({
    url: '/mk/equipments/' + equipmentNo,
    method: 'delete'
  })
}
// 修改设备
export function updateEquipment(data) {
  return request({
    url: '/mk/equipments',
    method: 'put',
    data: data
  })
}

// 新增设备
export function addEquipment(data) {
  return request({
    url: '/mk/equipments',
    method: 'post',
    data: data
  })
}

//设备下发
export function deviceControl(deviceType, deviceId, cmdData) {
  const data = {
    deviceType,
    deviceId,
    cmdData
  }
  console.log("传给deviceControl接口数据", data)
  return request({
    'url': '/mk/equipments/deviceControl',
    'method': 'post',
    'data': data
  })
}

// 设备上传图片
export function deviceImgUploadAdd(data) {
  return upload({
    url: '/mk/deviceresourcepath/deviceImgUploadAdd/' + data.equipmentNo,
    name: data.name,
    filePath: data.filePath,
    formData: {
      equipmentTypeId: data.equipmentTypeId
    }
  })
}
// 设备上传多文件图片
export function devicemultipleimages(data) {
  return upload({
    url: '/system/file/fileUploads',
    name: data.name,
    fileOneType: data.fileOneType,
    formData: {
      // equipmentTypeId: data.equipmentTypeId
      files: data.filePath,
    }
  })
}

// 根据设备编码查询设备上传图片列表
export function getMyUploadImgList(query) {
  return request({
    url: '/mk/deviceresourcepath/list',
    method: 'get',
    params: query
  })
}

//根据设备类型查询设备的上传路径
export function getEquipmentIdImg(equipmentId) {
  return request({
    url: '/mk/equipmentType/' + equipmentId,
    method: 'get'
  })
}

//查询设备所有类型
export function getEquipmentlist(query) {
  return request({
    url: '/mk/equipmentType/queryByList',
    method: 'get',
    params: query
  })
}
//查询设备类型详细
export function getEquipmentDetaile(equipmentTypeId) {
  return request({
    url: '/mk/equipmentType/' + equipmentTypeId,
    method: 'get'
  })
}

// 新增设备类型订单表
export function addOrder(data) {
  return request({
    url: '/xdj/order',
    method: 'post',
    data: data
  })
}

// 查询设备类型订单表列表
export function listOrder(query) {
  return request({
    url: '/xdj/order/list',
    method: 'get',
    params: query
  })
}

// 查询设备类型订单表详细
export function getOrder(id) {
  return request({
    url: '/xdj/order/' + id,
    method: 'get'
  })
}

// 修改设备类型订单表
export function updateOrder(data) {
  return request({
    url: '/xdj/order',
    method: 'put',
    data: data
  })
}

// 删除设备类型订单表
export function delOrder(id) {
  return request({
    url: '/xdj/order/' + id,
    method: 'delete'
  })
}

